import {request} from '@/plugins/request'

export const getArticles = params => {
    return request({
        method:'GET',
        url:'/api/articles',
        params
    })
}

export const addArticle = data => {
    return request({
        method:'POST',
        url:'/api/articles',
        data:data
    })
}

export const getYourFeedArticles = params => {
    return request({
        method:'GET',
        url:'/api/articles/feed',
        params
    })
}

export const addFavorite = slug => {
    return request({
        method:'POST',
        url:`/api/articles/${slug}/favorite`
    })
}

export const deleteFavorite = slug => {
    return request({
        method:'DELETE',
        url:`/api/articles/${slug}/favorite`
    })
}

export const getArticle = slug => {
    return request({
        method:'GET',
        url:`/api/articles/${slug}`
    })
}

export const getComments = slug => {
    return request({
        method:'GET',
        url:`/api/articles/${slug}/comments`
    })
}